<?php
class cl_BasePage extends TdPage { 
	
	
		public $head;
		public $foot;
		public $loginform;
		public $indexsignup;
		public $subheader;
		
		private $username = "";
	
	  function __construct() {
	  		global $js;
	  		global $styles;
	  	
		    parent::__construct();
		    $this->title = "";  
		    
		    $styles = new TdStylesheet("styles");
		    $styles->setMinify(false);
		    $styles->addCSS("../public/css/main.css");
		
		    $js = new TdJavascript("scripts");
		    $js->setMinify(false);
		    $js->addJS("../public/js/jquery-1.4.4.min.js");
		    $js->addJS("../public/js/liquid.js");
		    
		    $this->addComponent($styles);
		    $this->addComponent($js);	    
	    
	  }
	  
	  
	  
	
	  function doInit() {
	  
	  		global $teardrop;
	  	 
		  	$this->head = new Header($teardrop->sysroot."/app/header.phtml");
		  	$this->head->title = $this->title;
		  	 
		  	if ($this->classname == "index") {
		  		$this->foot = new Footer($teardrop->sysroot."/app/index_footer.phtml");
		  	} else {
		  		$this->foot = new Footer($teardrop->sysroot."/app/footer.phtml");
		  	}
		  	 
		  	
		  	$this->indexsignup = new Index_Signupindex($teardrop->sysroot."/app/index/signupindex.phtml");
		  	$this->subheader = new Subheader($teardrop->sysroot."/app/subheader.phtml");		  	
		  
		  	if ($this->classname != "login") {
			  	$this->loginform = new Header_Loginform($teardrop->sysroot."/app/header/loginform.phtml");
			  	$this->subheader->loginform = $this->loginform;
		  	}
		  	
		  	// provvisorio
		    $user = $teardrop->readcookie("username");
		    if ($user != "") {
		  	  if (!isset($_SESSION["user"])) {
		  	  	$_SESSION["user"] = new cl_User("username", $user);
		  	  }
		    }
		  	
		  	// current logged in username from the session
	      if (isset($_SESSION['cl_username'])) {
	      	$this->username = $_SESSION['cl_username'];
	      }
	  }
	  
	  function setUsername($value) {
	  	$this->username = $value;
	  	$_SESSION['cl_username'] = $value;
	  }
	  function getUsername() {
	  	return $this->username;
	  }
}
?>
